<template>
    <div class="container">
        examplelist1
        <div>msg1:{{username}}</div>
        <div>
            <div v-for='item in dataList'>11</div>
        </div>
        <div>{{123 | money(123)}}</div>
        <div>{{user.name}}</div>
        <div><el-button>11</el-button></div>
    </div>
</template>

<script>
import { request } from '@/plugins/request'
import { getUserList } from '@/common/api.js'
import axios from 'axios'

export default {
    middleware: 'test01',//中间件验证
    name: 'examplelist1',
    layout: 'layout1',//使用布局1
    computed: {
        user() {
            return this.$store.state.user;
        }
    },
    methods: {
        async login () {
            const res = await getUserList();
            const user = res.data.content.dataList[0];

            console.log('res,user', user);
            return res.data;
        }
    },
    async asyncData (context) {
        const objdata = {
            username: '',
            dataList: [{
                id: 1,
            }],
        };
        await new Promise((resolve, reject) => {
            setTimeout(() => {
                objdata.username = 'John Smith';
                resolve();
            }, 2000)
        });
        // axios({
        //     method: 'GET',
        //     url: '/user/queryUserList.do',
        // }).then((res) => {
        //     console.log('res2', res.data.content.dataList);
        //     objdata.dataList = res.data.content.dataList;
        // })
        return objdata;
    },
    mounted() {
        this.login();
    }
}
</script>

<style scoped>
.container{ text-align: center; }
</style>
